<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="../static/vue2.js"></script>
    <script src="../static/vue-resource.min.js"></script>
</head>
<body>
<div id="app">
    <input type="button" @click="get()" value="点我异步获取数据(Get)">
    <ul>
        <li v-for="news in datas">{{ news.title }}</li>
    </ul>
</div>
<script>
window.onload = function() {
    var vm = new Vue({
        el: "#app",
        data: {
            datas:[]
        },
        mounted:function(){
            this.showData();
            //需要执行的方法可以在mounted中进行触发，其获取的数据可以赋到data中后，可以放在前面进行渲染
        },
        methods: {
            showData: function () {
                this.$http.jsonp('http://vue_api.test/').then(function (res) {
                    vm.datas = res.body.data;
                }, function (reason) {
                    console.log(reason)
                })
            }
        }
    })
}
</script>
</body>
</html>